<template>
  <div>
    <a
      v-for="(item,index) in list"
      :key="index"
      class="el-upload-list__item-name"
    >
      <!-- <i :class="'el-icon-'+getSuffixIcon(file.name)" />{{ file.name }} -->
      <svg-icon :icon-class="getSuffixIcon(item.name)" />{{ item.name }}
    </a>
  </div>
</template>

<script>
export default {
  name: 'PureAttachmentList',
  props: {
    list: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  methods: {
    getSuffix(name) {
      return name.substring(name.lastIndexOf('.') + 1);
    },
    getSuffixIcon(name) {
      const suffix = this.getSuffix(name) || '';
      switch (suffix.toLowerCase()) {
        case 'jpg':
        case 'jpeg':
          return 'type-jpg';
        case 'png':
          return 'type-png';
        case 'gif':
          return 'type-gif';
        case 'rar':
          return 'type-rar';
        case 'zip':
          return 'type-zip';
        case 'doc':
        case 'docx':
          return 'type-doc';
        case 'xls':
        case 'xlsx':
          return 'type-xls';
        case 'pdf':
          return 'type-pdf';
        case 'txt':
          return 'type-txt';
        case 'pptx':
          return 'type-ppt';
        default:
          return '';
      }
    },
  },
};
</script>

<style lang="scss" scoped>

</style>
